﻿using System;
using fastCSharp;

namespace diantou.web.management
{
    /// <summary>
    /// 编辑比赛
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true)]
    partial class contestEdit : adminView<contestEdit>
    {
        /// <summary>
        /// 比赛
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private diantou.dataAccess.contest contest;
        /// <summary>
        /// 是否复制比赛
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private bool isCopy;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="contestId"></param>
        /// <returns></returns>
        private bool loadView(int contestId, int copyId)
        {
            if (contestId == 0)
            {
                isCopy = true;
                contestId = copyId;
            }
            if (contestId == 0)
            {
                DateTime now = date.NowSecond;
                contest = diantou.dataAccess.contest.NullContest;
                contest.StartTime = new DateTime(now.Year, now.Month, now.Day).AddDays(1);
                contest.EndTime = contest.StartTime.AddDays(1);
            }
            else
            {
                contest = diantou.dataAccess.clientCache.Contest[contestId];
                if (isCopy)
                {
                    contest = contest.Clone();
                    DateTime now = date.NowSecond;
                    contest.Id = 0;
                    contest.StartTime = new DateTime(now.Year, now.Month, now.Day).AddDays(1);
                    contest.EndTime = contest.StartTime.AddDays(1);
                }
            }
            return true;
        }
    }
}
